# --*-- coding:utf8 --*--
import multiprocessing

import html_automated_testing
import html_compatibility_testing
import html_destructive_testing
import html_function_testing
import html_performance_testing
import html_production_performance_testing
from dataopts.down_automated_testing import down_automated_testing
from dataopts.down_compatibility_testing import down_compatibility_testing
from dataopts.down_destructive_testing import down_destructive_testing
from dataopts.down_function_testing import down_function_testing
from dataopts.down_merge import down_merge
from dataopts.down_performance_testing import down_performance_testing
from dataopts.down_production_performance_testing import down_production_performance_testing
from mapping import Pie, Sunburst
from mapping.work import PieData, sunburstData, Dataforjson
from tools import conf


def run_automated_pie():
    for name in conf.automated_values.keys():
        html_automated_testing.parseData(name)
        for x, y in enumerate(conf.automated_values[name]["colname"]):
            Pie.myPie(PieData(x), y)


def run_compatibility_pie():
    for name in conf.compatibility_values.keys():
        html_compatibility_testing.parseData(name)
        for x, y in enumerate(conf.compatibility_values[name]["colname"]):
            Pie.myPie(PieData(x), y)


def run_destructive_pie():
    for name in conf.destructive_values.keys():
        html_destructive_testing.parseData(name)
        for x, y in enumerate(conf.destructive_values[name]["colname"]):
            Pie.myPie(PieData(x), y)


def run_function_pie():
    for name in conf.function_values.keys():
        html_function_testing.parseData(name)
        for x, y in enumerate(conf.function_values[name]["colname"]):
            Pie.myPie(PieData(x), y)


def run_performance_pie():
    for name in conf.performance_values.keys():
        html_performance_testing.parseData(name)
        for x, y in enumerate(conf.performance_values[name]["colname"]):
            Pie.myPie(PieData(x), y)


def run_production_performance_pie():
    for name in conf.production_performance_values.keys():
        html_production_performance_testing.parseData(name)
        for x, y in enumerate(conf.production_performance_values[name]["colname"]):
            Pie.myPie(PieData(x), y)


def run_auto_sunburst():
    for name in conf.automated_values.keys():
        html_automated_testing.parseData(name)
        for x, y in enumerate(conf.automated_values[name]["colname"]):
            Sunburst.sun(sunburstData(x), y)


def run_compatibility_sunburst():
    for name in conf.compatibility_values.keys():
        html_compatibility_testing.parseData(name)
        for x, y in enumerate(conf.compatibility_values[name]["colname"]):
            Sunburst.sun(sunburstData(x), y)


def run_destructive_sunburst():
    for name in conf.destructive_values.keys():
        html_destructive_testing.parseData(name)
        for x, y in enumerate(conf.destructive_values[name]["colname"]):
            Sunburst.sun(sunburstData(x), y)


def run_function_sunburst():
    for name in conf.function_values.keys():
        html_function_testing.parseData(name)
        for x, y in enumerate(conf.function_values[name]["colname"]):
            Sunburst.sun(sunburstData(x), y)


def run_performance_sunburst():
    for name in conf.performance_values.keys():
        html_performance_testing.parseData(name)
        for x, y in enumerate(conf.performance_values[name]["colname"]):
            Sunburst.sun(sunburstData(x), y)


def run_production_performance_sunburst():
    for name in conf.production_performance_values.keys():
        html_production_performance_testing.parseData(name)
        for x, y in enumerate(conf.production_performance_values[name]["colname"]):
            Sunburst.sun(sunburstData(x), y)


def run_automated_json():
    for name in conf.automated_values.keys():
        html_automated_testing.parseData(name)
        for x, y in enumerate(conf.automated_values[name]["colname"]):
            Dataforjson(x, y)


def run_compatibility_json():
    for name in conf.compatibility_values.keys():
        html_compatibility_testing.parseData(name)
        for x, y in enumerate(conf.compatibility_values[name]["colname"]):
            Dataforjson(x, y)


def run_destructive_json():
    for name in conf.destructive_values.keys():
        html_destructive_testing.parseData(name)
        for x, y in enumerate(conf.destructive_values[name]["colname"]):
            Dataforjson(x, y)


def run_function_json():
    for name in conf.function_values.keys():
        html_function_testing.parseData(name)
        for x, y in enumerate(conf.function_values[name]["colname"]):
            Dataforjson(x, y)


def run_performance_json():
    for name in conf.performance_values.keys():
        html_performance_testing.parseData(name)
        for x, y in enumerate(conf.performance_values[name]["colname"]):
            Dataforjson(x, y)


def run_production_performance_json():
    for name in conf.production_performance_values.keys():
        html_production_performance_testing.parseData(name)
        for x, y in enumerate(conf.production_performance_values[name]["colname"]):
            Dataforjson(x, y)


if __name__ == '__main__':
    down_automated_testing()
    down_compatibility_testing()
    down_destructive_testing()
    down_function_testing()
    down_performance_testing()
    down_production_performance_testing()
    down_merge()

    # auto_pie = multiprocessing.Process(target=run_automated_pie)
    # compatibility_pie = multiprocessing.Process(target=run_compatibility_pie)
    # destructive_pie = multiprocessing.Process(target=run_destructive_pie)
    # function_pie = multiprocessing.Process(target=run_function_pie)
    # performance_pie = multiprocessing.Process(target=run_performance_pie)
    # production_performance_pie = multiprocessing.Process(target=run_production_performance_pie)

    # auto_pie.start()
    # compatibility_pie.start()
    # destructive_pie.start()
    # function_pie.start()
    # performance_pie.start()
    # production_performance_pie.start()

    # auto_sunburst = multiprocessing.Process(target=run_auto_sunburst)
    # compatibility_sunburst = multiprocessing.Process(target=run_compatibility_sunburst)
    # destructive_sunburst = multiprocessing.Process(target=run_destructive_sunburst)
    # function_sunburst = multiprocessing.Process(target=run_function_sunburst)
    # performance_sunburst = multiprocessing.Process(target=run_performance_sunburst)
    # production_performance_sunburst = multiprocessing.Process(target=run_production_performance_sunburst)

    # auto_sunburst.start()
    # compatibility_sunburst.start()
    # destructive_sunburst.start()
    # function_sunburst.start()
    # performance_sunburst.start()
    # production_performance_sunburst.start()

    auto_json = multiprocessing.Process(target=run_automated_json)
    # compatibility_json = multiprocessing.Process(target=run_compatibility_json)
    # destructive_json = multiprocessing.Process(target=run_destructive_json)
    # function_json = multiprocessing.Process(target=run_function_json)
    # performance_json = multiprocessing.Process(target=run_performance_json)
    # production_performance_json = multiprocessing.Process(target=run_production_performance_json)

    auto_json.start()
    # compatibility_json.start()
    # destructive_json.start()
    # function_json.start()
    # performance_json.start()
    # production_performance_json.start()
